package com;// 案例 二 ，同上
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Filename:    AccessControlAllowOriginFilter.java
 * Description:
 * Copyright:   Copyright (c) 2022-2025 All Rights Reserved.
 * Company:     chinasofti.com Inc.
 * @author:     mazheng
 * @version:    1.0
 * Create at:   2022-08-19
 *
 * Modification History:
 * Date         Author      Version     Description       tag
 * ------------------------------------------------------------------
 * ${date}      jiangqi      1.0         1.0 Version
 * ${date}      mazheng      1.0         1.0 Version      rev
 *
 */
@Configuration
public class AccessControlAllowOriginFilter implements WebMvcConfigurer {

    /**
     * cors 跨域设置
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry){
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedMethods("*")
                .maxAge(1800)
                .allowedOrigins("*");
    }
}